package moonstar;

import moonstar.Factory.IFactory;
import moonstar.employee.Employee;

import java.lang.reflect.InvocationTargetException;
import java.util.Scanner;

public class application {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Scanner scanner = new Scanner(System.in);
        while (true){
            System.out.println("暂时有三种employee");
            System.out.println("1.Engineer");
            System.out.println("2.Manager");
            System.out.println("3.Sales");
            System.out.println("请输入对应的employee名称:");
            String next = scanner.next();
            if(next!="Engineer"&&next!="Manager"||next!="Sales") {
                IFactory factory = (IFactory) Class.forName("moonstar.Factory.IFactoryImpl." + next + "Factory").getConstructor().newInstance();
                Employee employee = factory.createEmployee();
                employee.printSalary();
            }else{
                throw new RuntimeException("输入错误!");
            }
        }
    }
}
